module Documenti::PreventiviHelper
  def preventivo_dettagli_preventivo_show_column(record)
    render :partial => 'dettagli_preventivo_show_column'
  end
  def list_row_class(record)
    case record.stato_documento.name
      #when 'accettato' then 'green'
      when 'inviato' then 'yellow'
      when 'sospeso' then 'yellow'
      when 'fatturato' then 'grey'
      when 'non accettato' then 'red'
      when 'sostituito' then 'red'
      when 'bozza' then 'purple'
      when 'VERIFICARE' then 'purple'
    else ''
    end
  end
  def options_for_association_conditions(association)
    if association.name == :contatto
      {'contatti.contatto_ref_id' => @record.partner_id}
    else
      super
    end
  end
  def preventivo_user_form_column(record, options)
    if record.user_id == nil
      select("record", "user", User.all.map {|i|
        [i.name, i.id]}, {:selected => current_user.id}, 
          :name => "record[user][id]")
    else
      select("record", "user", User.all.map {|i|
        [i.name, i.id]}, {:selected => record.user_id}, 
          :name => "record[user][id]")
    end
  end
end
